

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <title>Tab 选项卡 - 通过 JavaScript 调用 - MDUI 框架示例,Material Design 示例</title>
    <link rel="stylesheet" href="../assets/mdui-v0.4.0/css/mdui.min.css"/>
    <link rel="stylesheet" href="../assets/demo/css/demo.css"/>
    

</head>
<body>


<div class="preview-container"></div>

<div class="editor-panel">

    <div class="editor-controls mdui-p-x-1">

        <div class="editor-control-html mdui-ripple editor-control-active" onclick="Editor.toogleHTML();">HTML</div>
        <div class="editor-control-css mdui-ripple " onclick="Editor.toogleCSS();">CSS</div>
        <div class="editor-control-js mdui-ripple editor-control-active" onclick="Editor.toogleJS();">JavaScript</div>

        <div class="editor-controls-drag"></div>

        <div class="editor-controls-run mdui-btn mdui-btn-icon mdui-ripple mdui-m-x-1 mdui-text-color-black-secondary" mdui-tooltip="{content: '运行 Ctrl + Enter'}" onclick="Editor.run();"><i class="mdui-icon material-icons">play_arrow</i></div>
        <label class="editor-controls-live-mode mdui-switch mdui-m-x-1" mdui-tooltip="{content: '实时预览'}" onchange="Editor.toogleLiveMode();">
            <input type="checkbox" checked/>
            <i class="mdui-switch-icon"></i>
        </label>
        <!--<div class="mdui-controls-download mdui-btn mdui-btn-icon mdui-ripple mdui-m-x-1" mdui-tooltip="{content: '下载'}" onclick="Editor.download();"><i class="mdui-icon material-icons">file_download</i></div>-->

    </div>

    <div class="editor-container editor-container-html">
        <div class="editor-container-label">HTML</div>
        <pre id="editor-ace-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;
  &lt;title&gt;Tab 选项卡 - 通过 JavaScript 调用&lt;/title&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;../assets/mdui-v0.4.0/css/mdui.min.css&quot;/&gt;
&lt;/head&gt;
&lt;body style=&quot;padding-top: 20px;&quot;&gt;

&lt;div class=&quot;mdui-container&quot;&gt;
  &lt;div class=&quot;mdui-tab&quot; id=&quot;tab&quot;&gt;
    &lt;a href=&quot;#tab1-content&quot; id=&quot;tab1&quot; class=&quot;mdui-ripple&quot;&gt;web&lt;/a&gt;
    &lt;a href=&quot;#tab2-content&quot; id=&quot;tab2&quot; class=&quot;mdui-ripple&quot;&gt;shopping&lt;/a&gt;
    &lt;a href=&quot;#tab3-content&quot; id=&quot;tab3&quot; class=&quot;mdui-ripple&quot;&gt;images&lt;/a&gt;
  &lt;/div&gt;
  &lt;div id=&quot;tab1-content&quot; class=&quot;mdui-p-a-2&quot;&gt;web content&lt;/div&gt;
  &lt;div id=&quot;tab2-content&quot; class=&quot;mdui-p-a-2&quot;&gt;shopping content&lt;/div&gt;
  &lt;div id=&quot;tab3-content&quot; class=&quot;mdui-p-a-2&quot;&gt;images content&lt;/div&gt;


  &lt;button id=&quot;prev&quot; class=&quot;mdui-btn mdui-color-pink-accent mdui-m-a-1&quot;&gt;prev&lt;/button&gt;
  &lt;button id=&quot;next&quot; class=&quot;mdui-btn mdui-color-pink-accent mdui-m-a-1&quot;&gt;next&lt;/button&gt;
  &lt;br/&gt;
  &lt;button id=&quot;show-first&quot; class=&quot;mdui-btn mdui-color-pink-accent mdui-m-a-1&quot;&gt;show first&lt;/button&gt;
  &lt;button id=&quot;show-second&quot; class=&quot;mdui-btn mdui-color-pink-accent mdui-m-a-1&quot;&gt;show-second&lt;/button&gt;
&lt;/div&gt;

&lt;script src=&quot;../assets/mdui-v0.4.0/js/mdui.min.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
    </div>
    <div class="editor-container editor-container-css">
        <div class="editor-container-label">CSS</div>
        <pre id="editor-ace-css"></pre>
    </div>
    <div class="editor-container editor-container-js">
        <div class="editor-container-label">JavaScript</div>
        <pre id="editor-ace-js">var inst = new mdui.Tab('#tab');

// method

document.getElementById('prev').addEventListener('click', function () {
  inst.prev();
});

document.getElementById('next').addEventListener('click', function () {
  inst.next();
});

document.getElementById('show-first').addEventListener('click', function () {
  inst.show(0);
});

document.getElementById('show-second').addEventListener('click', function () {
  inst.show('tab2');
});

// event

document.getElementById('tab').addEventListener('change.mdui.tab', function (event) {
  console.log('event: change; tab: ' + event._detail.index);
});

document.getElementById('tab1').addEventListener('show.mdui.tab', function () {
  console.log('event: show; tab: 0');
});

document.getElementById('tab2').addEventListener('show.mdui.tab', function () {
  console.log('event: show; tab 1');
});

document.getElementById('tab3').addEventListener('show.mdui.tab', function () {
  console.log('event: show; tab 2');
});
</pre>
    </div>

</div>

<script src="../assets/mdui-v0.4.0/js/mdui.min.js"></script>
<script src="../assets/ace-1.2.6/ace.js"></script>
<script src="../assets/ace-1.2.6/ext-language_tools.js"></script>
<script src="../assets/demo/js/live-editor.js"></script>
<script>
  var Editor = new LiveEditor();
</script>
</body>
</html>